/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package queenb.web.controller.project;
import java.util.ArrayList;
import java.util.List;
import queenb.net.entitybean.B050;
import queenb.net.entitybean.N100;
import queenb.web.controller.QueenbController;
import queenb.web.permission.store.B050Store;
import queenb.web.util.Util;
/**
 *
 * @author ems
 */
public class ProjectController extends QueenbController{
    private int pb050;
    private String bv051;
    private String bv052;
    private String bv054;
    private B050Store b050Store;
    private String pageLoad;
    
    private List<N100> list = new ArrayList<N100>();
    public ProjectController() {
        b050Store = new B050Store();
        
        
         Object pb500Object = getRequest().getParameter("pb050");
         if(pb500Object != null)
         {
             this.pb050 = Util.parseInt(pb500Object);
             getListProjectDetail(pb050);
         }
    }
    
    
    
    public List<B050> getListProjectAll()
    {
        try {
            List<B050> listProject = b050Store.getListB050All(getLogin().getModule(),getLogin().getCompanyNo(), null, getLogin().getUserName());
            return listProject;
        } catch (Exception e) {
            return null;
        }

    }
    
    
    
   public void getListProjectDetail(int idpb050)
   {
       this.pb050 = idpb050;
       if(idpb050 != 0)
       {
           List<B050> listDetail = getListProjectAll();
           if(listDetail.size() > 0)
           {
               for(int i=0;i < listDetail.size();i++)
               {
                   if(listDetail.get(i).getPB050() == pb050)
                   {
                       this.bv051 = listDetail.get(i).getBV051();
                       this.bv052 = listDetail.get(i).getBV052();
                       this.bv054 = listDetail.get(i).getBV054();
                   }
                   
               }
           }
       }
   }
    
    public void updateProject()
    {
        int count = 0;
     
        count = b050Store.update(pb050, getLogin().getModule(), getLogin().getCompanyNo(), 0, 0, 0, bv051, bv052, null, this.bv054,0, 0, 0, 0, 0, null, 0, 0, getLogin().getUserName());
        if(count >=0)
        {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        }
        
        sendRedirect("project.jsp");
    }
    

    /**
     * @return the list
     */
    
    
    
    public List<N100> getList() {
        for(int i=0; i < 5 ; i++){
            list.add(new N100());
        }
        return list;
    }

    /**
     * @param list the list to set
     */
    public void setList(List<N100> list) {
        this.list = list;
    }

    /**
     * @return the pb050
     */
    public int getPb050() {
        return pb050;
    }

    /**
     * @param pb050 the pb050 to set
     */
    public void setPb050(int pb050) {
        this.pb050 = pb050;
    }

    /**
     * @return the bv051
     */
    public String getBv051() {
        return bv051;
    }

    /**
     * @param bv051 the bv051 to set
     */
    public void setBv051(String bv051) {
        this.bv051 = bv051;
    }

    /**
     * @return the bv052
     */
    public String getBv052() {
        return bv052;
    }

    /**
     * @param bv052 the bv052 to set
     */
    public void setBv052(String bv052) {
        this.bv052 = bv052;
    }

    /**
     * @return the bv054
     */
    public String getBv054() {
        return bv054;
    }

    /**
     * @param bv054 the bv054 to set
     */
    public void setBv054(String bv054) {
        this.bv054 = bv054;
    }

    /**
     * @return the pageLoad
     */
    public String getPageLoad() {
        return pageLoad;
    }

    /**
     * @param pageLoad the pageLoad to set
     */
    public void setPageLoad(String pageLoad) {
        this.pageLoad = pageLoad;
    }
}
